<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="一个简单的博客" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>Git |  空唤晴</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/atom.xml" title="空唤晴" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      <canvas class="fireworks"></canvas>
      <style>
        .fireworks {
          position: fixed;
          left: 0;
          top: 0;
          z-index: 99999;
          pointer-events: none;
        }
      </style>
      
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-其它/工具/git"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Git
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/14/%E5%85%B6%E5%AE%83/%E5%B7%A5%E5%85%B7/git/" class="article-date">
  <time datetime="2023-05-14T03:01:41.000Z" itemprop="datePublished">2023-05-14</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%85%B6%E5%AE%83/">其它</a> / <a class="article-category-link" href="/categories/%E5%85%B6%E5%AE%83/%E5%B7%A5%E5%85%B7/">工具</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">2.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">8 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="Git"><a href="#Git" class="headerlink" title="Git"></a>Git</h1><hr>
<h2 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h2><p>Git 是用来对代码进行版本管理和多人协作的代码仓库。</p>
<blockquote>
<p>Git 不区分文件名大小写，这在重命名文件时（仅更新文件名大小写）可能会造成隐患。</p>
</blockquote>
<h3 id="存储区域"><a href="#存储区域" class="headerlink" title="存储区域"></a>存储区域</h3><p><img src="/pic/git.png" alt="git"></p>
<ul>
<li><p><strong>Workspace 工作区</strong> </p>
<p>当前开发者正在进行编写的代码版本。</p>
</li>
<li><p><strong>Index 暂存区</strong> </p>
<p>【目录树结构】记录要进行版本管理的文件名、文件状态信息以及指向文件的索引。</p>
<p>通过使用时间戳、文件长度等状态信息，可以快速判断工作区文件是否被修改。</p>
</li>
<li><p><strong>Repository 仓库区</strong> </p>
<p>【日志结构】记录所有版本提交的历史更改，保存在 Git 对象库（.git/objects）中。</p>
<p>通过读取仓库区，可以将工作区代码回退到任意版本。</p>
</li>
<li><p><strong>Remote 远程仓库</strong></p>
<p>【日志结构】将本地仓库保存在远程服务器中，如 Github/Gitlab/Gitee 等知名第三方代码托管网站。</p>
<p>通过同步远程仓库，可以便捷地进行远程开发和多人协作。</p>
</li>
</ul>
<hr>
<h2 id="初始配置"><a href="#初始配置" class="headerlink" title="初始配置"></a>初始配置</h2><h3 id="安装本地仓库"><a href="#安装本地仓库" class="headerlink" title="安装本地仓库"></a>安装本地仓库</h3><p>点击下方链接下载 Git ，即可通过 Git Bash 工具使用 Git 命令。</p>
<blockquote>
<p>下载地址：<a target="_blank" rel="noopener" href="https://git-scm.com/">https://git-scm.com/</a></p>
</blockquote>
<p><em>如果想要直接在控制台使用 git 命令，还需要配置环境变量：在 Path 中添加 Git/cmd 文件夹路径。</em></p>
<h3 id="链接远程仓库"><a href="#链接远程仓库" class="headerlink" title="链接远程仓库"></a>链接远程仓库</h3><p>如果想通过远程仓库托管代码，还需要将本地 Git 链接到第三方的远程仓库中，如 Github/Gitlab/Gitee 等知名第三方代码托管网站。</p>
<blockquote>
<p>Github 官方网址：<a target="_blank" rel="noopener" href="https://github.com/">https://github.com/</a></p>
</blockquote>
<p>本地 Git 尝试对远程仓库修改时必须持有密钥，否则远程仓库将拒绝访问。</p>
<p>通过 Git Bash 命令生成本地密钥，然后添加到 Github 账号 SSH and GPG keys 选项中即可。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ ssh-keygen -t rsa -b 4096 -C <span class="string">&quot;email@example.com&quot;</span>        <span class="comment"># 生成密钥</span></span><br><span class="line">$ clip &lt; ~/.ssh/id_rsa.pub                                <span class="comment"># 将密钥复制到剪切板</span></span><br></pre></td></tr></table></figure>

<hr>
<h2 id="创建项目"><a href="#创建项目" class="headerlink" title="创建项目"></a>创建项目</h2><h3 id="本地创建"><a href="#本地创建" class="headerlink" title="本地创建"></a>本地创建</h3><p>如果要使用 Git 管理目录内的文件，需要将目录创建为 Git 代码仓库。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git init                             <span class="comment"># 在现有目录创建 git </span></span><br><span class="line">git init myProject                   <span class="comment"># 创建子目录并为子目录创建 git</span></span><br></pre></td></tr></table></figure>

<p>为已创建的本地仓库链接远程仓库，每个远程仓库链接都有独立的标识。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git remote add origin git@github.com:account/project.git      <span class="comment"># 绑定远程仓库，命名为 origin</span></span><br><span class="line">git remote <span class="built_in">rm</span> origin                                          <span class="comment"># 移除远程仓库 origin</span></span><br><span class="line">git remote -v                                                 <span class="comment"># 查看绑定的远程仓库</span></span><br></pre></td></tr></table></figure>

<h3 id="远程克隆"><a href="#远程克隆" class="headerlink" title="远程克隆"></a>远程克隆</h3><p>远程仓库中的项目拥有唯一的标识 SSH: 如 <code>git@github.com:account/project.git</code> 。用户可以直接拷贝到本地。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> git@github.com:account/project.git                  <span class="comment"># 拷贝项目到本地，并自动链接远程仓库</span></span><br></pre></td></tr></table></figure>


<hr>
<h2 id="基本使用"><a href="#基本使用" class="headerlink" title="基本使用"></a>基本使用</h2><h3 id="暂存文件-add"><a href="#暂存文件-add" class="headerlink" title="暂存文件 add"></a>暂存文件 add</h3><p>需要进行版本管理的代码文件应首先放入暂存区。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">git add README.md                          <span class="comment"># 将指定文件放入暂存区</span></span><br><span class="line">git add .                                  <span class="comment"># 将全部文件放入暂存区</span></span><br><span class="line"></span><br><span class="line">git diff                                   <span class="comment"># 查看工作区更新（相对于暂存区）</span></span><br><span class="line">git diff master                            <span class="comment"># 查看工作区更新（相对于 master 分支）</span></span><br><span class="line">git status                                 <span class="comment"># 查看文件是否被暂存或提交</span></span><br><span class="line"></span><br><span class="line">git checkout .                             <span class="comment"># 放弃工作区修改（但不会删除新建文件）</span></span><br><span class="line">git reset HEAD .                           <span class="comment"># 放弃暂存区修改（但不会改变工作区）</span></span><br></pre></td></tr></table></figure>

<p>在执行 add 操作时，开发者往往想要忽略一些特定的文件或目录。</p>
<p>我们可以通过在项目根目录下创建 <code>.gitignore</code> 文件记录忽略项的方式来实现，Git 在执行 add 操作时会自动跳过这些文件。
 </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># .gitignore 文件</span></span><br><span class="line"></span><br><span class="line">*.a                         <span class="comment"># 忽略所有 .a 结尾的文件</span></span><br><span class="line">!lib.a                      <span class="comment"># 但 lib.a 除外</span></span><br><span class="line"></span><br><span class="line">/TODO                       <span class="comment"># 忽略项目根目录下的 TODO 文件</span></span><br><span class="line"></span><br><span class="line">node_modules                <span class="comment"># 忽略指定文件夹</span></span><br><span class="line">.project</span><br><span class="line">.vscode</span><br><span class="line"></span><br><span class="line">build/                      <span class="comment"># 忽略 build/ 目录下的所有文件</span></span><br><span class="line">doc/*.txt                   <span class="comment"># 忽略 doc/ 目录下的 txt 文件</span></span><br></pre></td></tr></table></figure>

<p>尽管已更新了 <code>.gitignore</code> 文件，但暂存区仍可能保有历史文件的缓存数据。已提交过的文件如果想取消版本管理，要首先清除缓存。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">rm</span> -r --cached .idea                   <span class="comment"># 从暂存区删除文件夹</span></span><br><span class="line">git <span class="built_in">rm</span> -r --cached .                       <span class="comment"># 从暂存区删除全部文件 </span></span><br></pre></td></tr></table></figure>

<h3 id="提交版本-commit"><a href="#提交版本-commit" class="headerlink" title="提交版本 commit"></a>提交版本 commit</h3><p>通过执行 commit 操作，将暂存区中托管的文件数据存储到本地仓库保存。</p>
<p>commit 操作执行完毕后，暂存区数据会被清空。每次 commit 操作前都应执行 add 操作。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git commit -m <span class="string">&quot;Your commit&quot;</span>                <span class="comment"># 提交文件，放入 git 仓库保存</span></span><br><span class="line"></span><br><span class="line">git diff --staged                          <span class="comment"># 查看当前分支暂存区更新（相对于提交版本）</span></span><br><span class="line">git status                                 <span class="comment"># 查看文件是否被暂存或提交</span></span><br></pre></td></tr></table></figure>

<p>执行 commit 操作后（版本号 A）并尝试 push 到远程仓库，如果远程仓库已经被更新就会遭到拒绝。此时必须通过 pull 获取更新到本地然后合并（版本号 B）才能 push 代码，但是会提交两个版本更新。</p>
<p>此时可以改用 stash 操作对本地更改进行缓存，但不会产生新的提交对象（无论是否 add 默认情况下都会被缓存）。再执行 pull 操作时会直接读取远程仓库的版本，然后通过 stash pop 操作读取缓存并合并（版本号 B）。之后再进行 commit 和 push 操作，就只会提交一个版本更新。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">git stash                                  <span class="comment"># 将更改放入堆栈缓存</span></span><br><span class="line">git stash save <span class="string">&quot;save message&quot;</span>              <span class="comment"># 将更改放入堆栈缓存并命名</span></span><br><span class="line">  </span><br><span class="line">git stash apply                            <span class="comment"># 应用堆栈缓存中的更改但不清除</span></span><br><span class="line">git stash pop                              <span class="comment"># 读取堆栈缓存中的更改</span></span><br><span class="line"></span><br><span class="line">git stash list                             <span class="comment"># 查看堆栈缓存</span></span><br><span class="line">git stash show <span class="string">&quot;save message&quot;</span>              <span class="comment"># 查看指定堆栈缓存</span></span><br><span class="line">git stash clear                            <span class="comment"># 清空堆栈缓存</span></span><br></pre></td></tr></table></figure>


<h3 id="管理分支-branch"><a href="#管理分支-branch" class="headerlink" title="管理分支 branch"></a>管理分支 branch</h3><p>在创建仓库的时候，会默认创建主分支 master。HEAD 则始终指向当前分支。</p>
<p>在开发功能、修复 BUG 时，我们通常都会创建分支来进行操作，直到完成开发后再合并到主分支上。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">git branch                                 <span class="comment"># 列出本地分支（HEAD 指向当前分支）</span></span><br><span class="line">git branch -r                              <span class="comment"># 列出远程分支 </span></span><br><span class="line"></span><br><span class="line">git branch <span class="built_in">test</span>                            <span class="comment"># 创建 test 分支（但不切换）</span></span><br><span class="line">git checkout <span class="built_in">test</span>                          <span class="comment"># 切换到 test 分支</span></span><br><span class="line">git checkout -b <span class="built_in">test</span>                       <span class="comment"># 创建并切换到 test 分支</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># 当前分支未被修改时，merge 和 rebase 无区别</span></span><br><span class="line">git merge <span class="built_in">test</span>                             <span class="comment"># test 分支合并到当前分支（将两个分支合并，新建一个 commit）</span></span><br><span class="line">git merge origin/master                    <span class="comment"># origin/master 合并到当前分支   </span></span><br><span class="line">git rebase master                          <span class="comment"># master 分支合并到当前分支（当前分支重新执行另一个分支的全部 commit）</span></span><br><span class="line"></span><br><span class="line">git branch -D <span class="built_in">test</span>                         <span class="comment"># 删除分支</span></span><br></pre></td></tr></table></figure>

<p>当合并分支或者导入远程仓库分支时，常常会出现同一个文件被多个分支修改的情况。这个时候工作区文件会同时记录多个版本的代码，需要开发者通过编辑器解决冲突。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">git status                                                        <span class="comment"># 查看工作区和缓存区差异</span></span><br><span class="line">git <span class="built_in">log</span> -p master..origin/master                                  <span class="comment"># 查看两分支提交版本之间差异</span></span><br><span class="line"></span><br><span class="line">git <span class="built_in">log</span>                                                           <span class="comment"># 查看提交历史（会显示 commit ID）</span></span><br><span class="line">git <span class="built_in">log</span> README.txt                                                <span class="comment"># 查看指定文件提交历史（会显示 commit ID）</span></span><br><span class="line"></span><br><span class="line">git reset --hard f687a6de307a598d375bc1b6433dfe667c551f87         <span class="comment"># 版本回退（根据 commit ID）</span></span><br><span class="line">git reset f687a6de307a598d375bc1b6433dfe667c551f87 README.txt     <span class="comment"># 对指定文件版本回退（根据 commit ID）</span></span><br></pre></td></tr></table></figure>


<h3 id="远程同步-push-pull"><a href="#远程同步-push-pull" class="headerlink" title="远程同步 push / pull"></a>远程同步 push / pull</h3><p>本地仓库和远程仓库链接后，且本地 Git 绑定的 GitHub 账户具备对远程仓库的操作权限，用户就可以通过以下指令同步远程代码。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">git push -u origin master                                     <span class="comment"># master 分支上传到远程仓库 origin（上传新分支会在远程仓库也创建新分支）</span></span><br><span class="line">git push -f origin master                                     <span class="comment"># master 分支强制上传到远程仓库 origin（适用于版本回退后远程同步）</span></span><br><span class="line"></span><br><span class="line">git pull origin master                                        <span class="comment"># 从远端仓库 origin 获取代码并自动合并到主分支</span></span><br><span class="line">git status                                                    <span class="comment"># 导入后工作区更新，查看和之前版本的差异</span></span><br><span class="line"></span><br><span class="line">git fetch origin master                                       <span class="comment"># 从远端仓库 origin 获取 origin/master 分支</span></span><br><span class="line">git <span class="built_in">log</span> -p master..origin/master                              <span class="comment"># 查看分支差异</span></span><br><span class="line">git merge origin/master                                       <span class="comment"># 合并分支</span></span><br></pre></td></tr></table></figure>


<h3 id="合作开发-fork"><a href="#合作开发-fork" class="headerlink" title="合作开发 fork"></a>合作开发 fork</h3><p>Github 等远程仓库支持多人对同一项目进行协同开发，主要有以下两种形式。</p>
<ul>
<li><p><strong>collaborators 模式</strong></p>
<p>适用于小组合作开发。</p>
<ol>
<li>仓库所有者进入仓库设置，在 Collaborators 选项添加合作者。</li>
<li>合作者有权限对直接对指定的远程仓库进行修改。</li>
</ol>
</li>
<li><p><strong>fork 模式</strong></p>
<p>适用于开源或大型项目。</p>
<ol>
<li><p>开发者选择 Fork 原仓库，复制得到自己持有的镜像仓库。</p>
</li>
<li><p>开发者对镜像仓库进行修改后，可以发送 Pull Request 询问原仓库拥有者是否想要该修改。</p>
</li>
<li><p>原仓库拥有者同意后，镜像仓库的修改会合并到原仓库中。</p>
</li>
</ol>
</li>
</ul>
<blockquote>
<p>协助开发者可以在本地仓库同时链接两个远程仓库：如 origin 自己持有的镜像仓库 &amp; upstream 原始仓库。本地仓库从 upstream 获取代码，更新后上传到 origin 并发送 Pull Request 请求。</p>
</blockquote>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://xlw686.github.io/2023/05/14/%E5%85%B6%E5%AE%83/%E5%B7%A5%E5%85%B7/git/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/yan/" rel="tag">yan</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%85%B6%E5%AE%83/" rel="tag">其它</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2023/05/14/%E5%85%B6%E5%AE%83/%E5%B7%A5%E5%85%B7/docker/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Docker
          
        </div>
      </a>
    
    
      <a href="/2023/05/14/%E5%85%B6%E5%AE%83/%E5%B7%A5%E5%85%B7/maven/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">Maven</div>
      </a>
    
  </nav>

  
   
  
   
    <script src="https://cdn.staticfile.org/twikoo/1.4.18/twikoo.all.min.js"></script>
    <div id="twikoo" class="twikoo"></div>
    <script>
        twikoo.init({
            envId: ""
        })
    </script>
 
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023
        <i class="ri-heart-fill heart_icon"></i> 空唤晴
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="空唤晴"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2023/01/01/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<script src="https://cdn.staticfile.org/animejs/3.2.1/anime.min.js"></script>

<script src="/js/clickBoom1.js"></script>
 
<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->
 
<script src="/js/dz.js"></script>
 
<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>